﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ERPStudio;
using System.Data.SqlClient;

namespace Fares
{
    public partial class StocuriProductieFrm : FrmRezumat
    {
        public Int16 IDcategorieSelectata = -1;
        public StocuriProductieFrm(ModuleClass mc):base(mc)
        {
            InitializeComponent();
            ReadOnly = true;
        }

        private void StocuriProductieFrm_Load(object sender, EventArgs e)
        {
            SqlConnection con = DeschideConexiune(workConnString);
            this.tipCategoriiArticoleTableAdapter.Connection = con;
            this.tipCategoriiArticoleTableAdapter.Fill(this.eSRPDataSetArticol.TipCategoriiArticole);
            this.fares_viewArticolProductieTableAdapter.Connection = con;
            if(IDcategorieSelectata==-1)
                this.fares_viewArticolProductieTableAdapter.Fill(this.eSRPDataSetArticol.fares_viewArticolProductie, ModuleInfo.CodUnitate);
            else
                this.fares_viewArticolProductieTableAdapter.FillByCategorie(this.eSRPDataSetArticol.fares_viewArticolProductie, ModuleInfo.CodUnitate,IDcategorieSelectata);
            InchideConexiune(con);
            denumireComboBox_SelectedIndexChanged(sender, e);

        }

        private void denumireComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (denumireCB.SelectedItem == null)
                return;
            DataSets.ESRPDataSetArticol.TipCategoriiArticoleRow rd = ((DataRowView)denumireCB.SelectedItem).Row
                as DataSets.ESRPDataSetArticol.TipCategoriiArticoleRow;
            SqlConnection con = DeschideConexiune(workConnString);
            this.fares_viewArticolProductieTableAdapter.Connection = con;
            this.fares_viewArticolProductieTableAdapter.FillByCategorie(this.eSRPDataSetArticol.fares_viewArticolProductie, ModuleInfo.CodUnitate, rd.IDCategorie);
            InchideConexiune(con);
        }
    }
}
